*This do file implements all the regression analyses reported in the paper and in the appendix.
	*note that for the regressions with controls, the "local" command must be executed in the same code chunk, or the controls will not work properly

*****************************************************************
*OLS models of voter recall as a function of political engagement.
*****************************************************************
*TABLE 2
*THOMAS
use "thomas_wide_data.dta", clear
local controls i.educ female i.race_wbh  i.age_cat  dem_lean gop_lean
eststo recall_thomas:  reg index_recall_correct_thomas  engage_factor_resc 
eststo recall_thomascont:  reg index_recall_correct_thomas  engage_factor_resc  `controls'

*SOTOMAYOR and KAGAN
use "CCES_soto_kagan_wide.dta", clear
local controls i.educ female i.race_wbh  i.age_cat  dem_lean gop_lean 

eststo recall_sk:   reg index_recall_correct_nominee engage_factor_resc
eststo recall_skcont:  reg index_recall_correct_nominee engage_factor_resc   `controls' 

*Make Table 2 for paper  
esttab recall_thomas recall_thomascont recall_sk recall_skcont using  "table_02.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS models of voter recall as a function of political engagement\label{table2})


*Table A-9 and A-10 separate results for Democrats and Republicans
	*DEMOCRATS
use "thomas_wide_data.dta", clear
local controls i.educ female i.race_wbh  i.age_cat  dem_lean gop_lean
eststo recall_thomas_dems:  reg index_recall_correct_thomas  engage_factor_resc if dem_lean==1
eststo recall_thomascont_dems:  reg index_recall_correct_thomas  engage_factor_resc  `controls' if dem_lean==1
use "CCES_soto_kagan_wide.dta", clear
local controls i.educ female i.race_wbh  i.age_cat  dem_lean gop_lean 
eststo recall_sk_dems:   reg index_recall_correct_nominee engage_factor_resc if dem_lean==1
eststo recall_skcont_dems:  reg index_recall_correct_nominee engage_factor_resc   `controls' if dem_lean==1

esttab recall_thomas_dems  recall_thomascont_dems recall_sk_dems recall_skcont_dems using  "table_A_09.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS models of voter recall as a function of political engagement,  Democrats only\label{tableA09})
	*REPUBLICANS
use "thomas_wide_data.dta", clear
local controls i.educ female i.race_wbh  i.age_cat  dem_lean gop_lean
eststo recall_thomas_gops:  reg index_recall_correct_thomas  engage_factor_resc if gop_lean==1
eststo recall_thomascont_gops:  reg index_recall_correct_thomas  engage_factor_resc  `controls' if gop_lean==1
use "CCES_soto_kagan_wide.dta", clear
local controls i.educ female i.race_wbh  i.age_cat  dem_lean gop_lean 
eststo recall_sk_gops:   reg index_recall_correct_nominee engage_factor_resc if gop_lean==1
eststo recall_skcont_gops:  reg index_recall_correct_nominee engage_factor_resc   `controls' if gop_lean==1

esttab recall_thomas_gops  recall_thomascont_gops recall_sk_gops recall_skcont_gops using  "table_A_10.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS models of voter recall as a function of political engagement,  Republicans only\label{tableA10})
	
*TABLE A-18: separate results for Sotomayor and Kagan
eststo recall_soto:   	 reg index_recall_correct_nominee engage_factor_resc if nominee=="sotomayor"
eststo recall_sotocont:  reg index_recall_correct_nominee engage_factor_resc   `controls'  if nominee=="sotomayor"
eststo recall_kagan:   	 reg index_recall_correct_nominee engage_factor_resc if nominee=="kagan"
eststo recall_kagancont: 	 reg index_recall_correct_nominee engage_factor_resc   `controls'  if nominee=="kagan"

esttab recall_soto recall_sotocont recall_kagan recall_kagancont  using  "table_A_18.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS models of voter recall as a function of political engagement,  Sotomayor and Kagan separately\label{tableA18})
	
	
	
*****************************************************************
*OLS regressions of voters' perceptions of how senators voted on nominees and the party of their senators
	*(SWITCH TO LONG DATA)
*****************************************************************
*TABLE 3, THOMAS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement sen_actual_ideo_agreement
*outcome: perceived thomas agreement 
eststo thomas_sen_perception_1:  reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(case_id)
eststo thomas_sen_perception_2:  reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement  `controls', cluster(case_id)
* outcome: perceived party agreement
eststo thomas_sen_perception_3:  reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(case_id)
eststo thomas_sen_perception_4:  reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement  `controls',  cluster(case_id)
*Make Table 3, thomas portion (top)
esttab thomas_sen_perception_1 thomas_sen_perception_2 thomas_sen_perception_3 thomas_sen_perception_4  using  "table_03_thomas.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS Regressions of voters' perceptions of Clarence Thomas vote and party of senator\label{table_03_thomas})

*TABLE 3, SOTO/KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
*outcome: perceived nominee agreement (
eststo nominee_sen_perception_1:  reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(case_id_new)
eststo nominee_sen_perception_2:  reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement `controls',  cluster(case_id_new)
* outcome: actual nominee agreement
eststo nominee_sen_perception_3:  reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(case_id_new)
eststo nominee_sen_perception_4:  reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement `controls',  cluster(case_id_new)

esttab nominee_sen_perception* using  "table_03_soto_kagan.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)  title(OLS Regressions of voters' perceptions of Sotomayor/Kagan vote and party of senator\label{table_03_sk})
	
*Table A-6, same models but SEs clustered on senator
*THOMAS
*outcome: perceived Thomas agreement 
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement sen_actual_ideo_agreement
eststo thomas_percep_sen_cluster_1: reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo thomas_percep_sen_cluster_2: reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement sen_actual_ideo_agreement `controls',  cluster(sen_icpsr)
* outcome: perceived party agreement
eststo thomas_percep_sen_cluster_3: reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo thomas_percep_sen_cluster_4: reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement sen_actual_ideo_agreement `controls',  cluster(sen_icpsr)

esttab thomas_percep_sen_cluster*  using  "table_A_06_thomas.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   title(Robustness check: perceptions of Thomas vote and party of senator clustered on senator\label{foo})
	
*SOTO/KAGAN	
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo sk_perception_sen_cluster_1: reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo sk_perception_sen_cluster_2: reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement  `controls', cluster(sen_icpsr)
eststo sk_perception_sen_cluster_3: reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo sk_perception_sen_cluster_4: reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement  `controls',  cluster(sen_icpsr)

*these go in appendix table-- with SEs clustered on senators
esttab sk_perception_sen_cluster*  using  "table_A_06_soto_kagan.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex) 	title(Robustness check: perceptions of Sotomayor/Kagan vote and party of senator clustered on senator\label{foo})

*TABLES A-11 and A-12: Separate results for Democrats and Republicans
	*DEMOCRATS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement sen_actual_ideo_agreement
*outcome: perceived thomas agreement 
eststo thomas_sen_perception_1_d:  reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id)
eststo thomas_sen_perception_2_d:  reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement  `controls' if dem_lean==1, cluster(case_id)
* outcome: perceived party agreement
eststo thomas_sen_perception_3_d:  reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id)
eststo thomas_sen_perception_4_d:  reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement  `controls' if dem_lean==1 ,  cluster(case_id)
*Make Table 3, thomas portion (top)
esttab thomas_sen_perception_1_d thomas_sen_perception_2_d thomas_sen_perception_3_d thomas_sen_perception_4_d  using  "table_A11_thomas.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS Regressions of voters' perceptions of Clarence Thomas vote and party of senator, Democrats only\label{table_A11_thomas})
	use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
*outcome: perceived nominee agreement (
eststo nominee_sen_perception_1_d:  reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id_new)
eststo nominee_sen_perception_2_d:  reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement `controls' if dem_lean==1,  cluster(case_id_new)
* outcome: actual nominee agreement
eststo nominee_sen_perception_3_d:  reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id_new)
eststo nominee_sen_perception_4_d:  reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement `controls' if dem_lean==1,  cluster(case_id_new)

esttab nominee_sen_perception_1_d nominee_sen_perception_2_d nominee_sen_perception_3_d nominee_sen_perception_4_d using  "table_A11_soto_kagan.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)  title(OLS Regressions of voters' perceptions of Sotomayor/Kagan vote and party of senator, Democrats only\label{table_03_sk})
	*REPUBLICANS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement sen_actual_ideo_agreement
*outcome: perceived thomas agreement 
eststo thomas_sen_perception_1_g:  reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id)
eststo thomas_sen_perception_2_g:  reg sen_perceived_thomas_agreement sen_actual_thomas_agreement sen_actual_party_agreement  `controls' if gop_lean==1, cluster(case_id)
* outcome: perceived party agreement
eststo thomas_sen_perception_3_g:  reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id)
eststo thomas_sen_perception_4_g:  reg sen_perceived_party_agreement sen_actual_thomas_agreement sen_actual_party_agreement  `controls' if gop_lean==1 ,  cluster(case_id)
*Make Table 3, thomas portion (top)
esttab thomas_sen_perception_1_g thomas_sen_perception_2_g thomas_sen_perception_3_g thomas_sen_perception_4_g  using  "table_A12_thomas.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(OLS Regressions of voters' perceptions of Clarence Thomas vote and party of senator, Democrats only\label{table_A11_thomas})
	use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
*outcome: perceived nominee agreement (
eststo nominee_sen_perception_1_g:  reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id_new)
eststo nominee_sen_perception_2_g:  reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement `controls' if gop_lean==1,  cluster(case_id_new)
* outcome: actual nominee agreement
eststo nominee_sen_perception_3_g:  reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id_new)
eststo nominee_sen_perception_4_g:  reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement `controls' if gop_lean==1,  cluster(case_id_new)

esttab nominee_sen_perception_1_g nominee_sen_perception_2_g nominee_sen_perception_3_g nominee_sen_perception_4_g using  "table_A12_soto_kagan.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)  title(OLS Regressions of voters' perceptions of Sotomayor/Kagan vote and party of senator, Republicans only\label{table_03_sk})
	
	
*Table A-19: Separate results for Sotomayor and Kagan
	*sotomayor

use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo s_perception_sen_cluster_1: reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement if nominee=="sotomayor",  cluster(case_id_new)
eststo s_perception_sen_cluster_2: reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement  `controls' if nominee=="sotomayor", cluster(case_id_new)
eststo s_perception_sen_cluster_3: reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement if nominee=="sotomayor",  cluster(case_id_new)
eststo s_perception_sen_cluster_4: reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement  `controls' if nominee=="sotomayor",  cluster(case_id_new)
esttab s_perception_sen_cluster*  using  "table_A_19_soto.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex) ///
	title(OLS regressions of voters' perceptions of nominee vote and party of senator, Sotomayor and Kagan separately\label{foo})
eststo k_perception_sen_cluster_1: reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement if nominee=="kagan",  cluster(case_id_new)
eststo k_perception_sen_cluster_2: reg sen_perc_nominee_agreement sen_actual_nominee_agreement sen_actual_party_agreement  `controls' if nominee=="kagan", cluster(case_id_new)
eststo k_perception_sen_cluster_3: reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement if nominee=="kagan",  cluster(case_id_new)
eststo k_perception_sen_cluster_4: reg sen_perc_party_agreement sen_actual_nominee_agreement sen_actual_party_agreement  `controls' if nominee=="kagan",  cluster(case_id_new)
esttab k_perception_sen_cluster*  using  "table_A_19_kagan.tex", /// 
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex) ///
	title(OLS regressions of voters' perceptions of nominee vote and party of senator, Sotomayor and Kagan separately\label{foo})

*******************************************************************************************
*Reduced form estimates: actual agreement and voter evaluations
*******************************************************************************************
*Table 4
*THOMAS
*VOTER APPROVAL
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_rf_approval_1: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(case_id)
eststo thomas_rf_approval_2: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement `controls',   cluster(case_id)

*VOTE CHOICE
keep if R_had_incumbent_elec==1 // keep only observations with incumbent senators
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
*each state has only 1 senator at most, so don't need respondent clustered standard errors for Thomas
eststo thomas_rf_vc_1: reg R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement
eststo thomas_rf_vc_2: reg  R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement `controls'

esttab thomas_rf_approval_1  thomas_rf_approval_2 thomas_rf_vc_1   thomas_rf_vc_2  using  "table_04_thomas.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form)\label{foo})

*SOTO/KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*APPROVAL
eststo sk_rf_approval_1: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(case_id_new)
eststo sk_rf_approval_2: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement `controls',   cluster(case_id_new)

*VOTE CHOICE (ONLY KAGAN)
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo sk_rf_vc_1: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(case_id_new)
eststo sk_rf_vc_2: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement `controls',   cluster(case_id_new)

esttab sk_rf_approval_1  sk_rf_approval_2 sk_rf_vc_1 sk_rf_vc_2 using  "table_04_soto_kagan.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form)\label{foo})
	
*Table A-7, 	OLS regression models of reduced form of actual agreement versus evaluation of senators, with standard errors clustered on senators.
*Thomas
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
	*approval
eststo thomas_rf_app_1_sencluster: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo thomas_rf_app_2_sencluster: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement `controls',   cluster(sen_icpsr)
*vote choice
keep if R_had_incumbent_elec==1 // keep only observations with incumbent senators
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_rf_vc_1_sencluster: reg  R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo thomas_rf_vc_2_sencluster: reg  R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement `controls',   cluster(sen_icpsr)

esttab thomas_rf_app_1_sencluster thomas_rf_app_2_sencluster thomas_rf_vc_1_sencluster thomas_rf_vc_2_sencluster  using  "table_A_07_thomas.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), with standard errors clustered on senator, Thomas\label{foo})
*SOTO/KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*approval
eststo sk_rf_app_1_sencluster: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo sk_rf_app_2_sencluster: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement `controls',   cluster(sen_icpsr)
*VOTE CHOICE (ONLY KAGAN)
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo sk_rf_vc_1_sencluster: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement,  cluster(sen_icpsr)
eststo sk_rf_vc_2_sencluster: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement `controls',   cluster(sen_icpsr)

esttab sk_rf_approval_1  sk_rf_approval_2 sk_rf_vc_1 sk_rf_vc_2 using  "table_A_07_soto_kagan.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), with standard errors clustered on senator, Sotomayor and Kagan\label{foo})

*Table A-13, separate results for Democrats and Republicans
	*Democrats
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_rf_approval_1_d: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id)
eststo thomas_rf_approval_2_d: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement `controls' if dem_lean==1,   cluster(case_id)
*VOTE CHOICE
keep if R_had_incumbent_elec==1 // keep only observations with incumbent senators
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_rf_vc_1_d: reg R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement if dem_lean==1
eststo thomas_rf_vc_2_d: reg  R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement `controls' if dem_lean==1
esttab thomas_rf_approval_1_d  thomas_rf_approval_2_d thomas_rf_vc_1_d   thomas_rf_vc_2_d  using  "table_A13_thomas.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), Thomas, Democrats only\label{foo})

*SOTO/KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*APPROVAL
eststo sk_rf_approval_1_d: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id_new)
eststo sk_rf_approval_2_d: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement `controls' if dem_lean==1,   cluster(case_id_new)
*VOTE CHOICE (ONLY KAGAN)
keep if nominee=="kagan"
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo sk_rf_vc_1_d: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement if dem_lean==1,  cluster(case_id_new)
eststo sk_rf_vc_2_d: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement `controls' if dem_lean==1,   cluster(case_id_new)

esttab sk_rf_approval_1_d  sk_rf_approval_2_d sk_rf_vc_1_d sk_rf_vc_2_d using  "table_A13_soto_kagan.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), Sotomayor and Kagan, Democrats only\label{foo})

	*REPUBLICANS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_rf_approval_1_g: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id)
eststo thomas_rf_approval_2_g: reg sen_approval_binary sen_actual_thomas_agreement sen_actual_party_agreement `controls' if gop_lean==1,   cluster(case_id)
*VOTE CHOICE
keep if R_had_incumbent_elec==1 // keep only observations with incumbent senators
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_rf_vc_1_g: reg R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement if gop_lean==1
eststo thomas_rf_vc_2_g: reg  R_vote_inc sen_actual_thomas_agreement sen_actual_party_agreement `controls' if gop_lean==1
esttab thomas_rf_approval_1_g  thomas_rf_approval_2_g thomas_rf_vc_1_g   thomas_rf_vc_2_g  using  "table_A14_thomas.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), Thomas, Republicans only\label{foo})

*SOTO/KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*APPROVAL
eststo sk_rf_approval_1_g: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id_new)
eststo sk_rf_approval_2_g: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement `controls' if gop_lean==1,   cluster(case_id_new)
*VOTE CHOICE (ONLY KAGAN)
keep if nominee=="kagan"
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo sk_rf_vc_1_g: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement if gop_lean==1,  cluster(case_id_new)
eststo sk_rf_vc_2_g: reg R_vote_inc sen_actual_nominee_agreement sen_actual_party_agreement `controls' if gop_lean==1,   cluster(case_id_new)

esttab sk_rf_approval_1_g  sk_rf_approval_2_g sk_rf_vc_1_g sk_rf_vc_2_g using  "table_A14_soto_kagan.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), Sotomayor and Kagan, Republicans only\label{foo})



*table A-20: separate results for Sotomayor and Kagan (just approval, since vote choice analysis is based solely on Kagan)
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*Sotomayor (APPROVAL)
eststo s_rf_approval_1: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement if nominee=="sotomayor",  cluster(case_id_new)
eststo s_rf_approval_2: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement `controls' if nominee=="sotomayor",   cluster(case_id_new)
*Kagan 
	*approval
eststo k_rf_approval_1: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement if nominee=="kagan",  cluster(case_id)
eststo k_rf_approval_2: reg sen_approval_binary sen_actual_nominee_agreement sen_actual_party_agreement `controls' if nominee=="kagan",   cluster(case_id_new)

esttab s_rf_approval_1 s_rf_approval_2 k_rf_approval_1 k_rf_approval_2  using  "table_A_20.tex", /// 
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Actual agreement and Senator Evaluations (Reduced Form), separate results for Sotomayor and Kagan\label{foo})
	
*************************************************
*TABLE 5 is calculated in the R script
*********************************************

*************************************************
*Perceptions and voter evaluations
*************************************************
*Table 6: Regression models evaluating whether perceptions about nominee votes affect eval-uation of senators.
*Thomas

use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*IV REGRESSIONS
eststo thomas_iv_approval_1: ivregress 2sls sen_approval_binary ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement), cluster(case_id) 
estat firststage, all
eststo thomas_iv_approval_2:ivregress 2sls  sen_approval_binary `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement), cluster(case_id)
estat firststage, all
*vote choice
keep if R_had_incumbent_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_iv_vc_1: ivregress 2sls  R_vote_inc ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement)
estat firststage, all
eststo thomas_iv_vc_2: ivregress 2sls  R_vote_inc `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement)
estat firststage, all

*OLS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_ols_approval_1: reg sen_approval_binary sen_perceived_thomas_agreement sen_perceived_party_agreement,  cluster(case_id) 
eststo thomas_ols_approval_2: reg sen_approval_binary sen_perceived_thomas_agreement sen_perceived_party_agreement `controls',   cluster(case_id)
*vote choice
keep if R_had_incumbent_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_ols_vc_1: reg  R_vote_inc sen_perceived_thomas_agreement sen_perceived_party_agreement
eststo thomas_ols_vc_2: reg  R_vote_inc sen_perceived_thomas_agreement sen_perceived_party_agreement `controls'

esttab  thomas_iv_approval_1 thomas_iv_approval_2  thomas_iv_vc_1 thomas_iv_vc_2 /// 
	thomas_ols_approval_1 thomas_ols_approval_2 thomas_ols_vc_1 thomas_ols_vc_2 ///
	using  "table_06_thomas.tex", /// 
	keep(sen_perceived_thomas_agreement sen_perceived_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Clarence Thomas\label{foo})	
	
*SOTOMAYOR AND KAGAN
	*note the regsave commands save the IV regressions with controls, for the later analyses comparing effects across issues
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*IV REGRESSIONS
*approval
eststo sk_iv_approval_1: ivregress 2sls sen_approval_binary  /// 
		(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) , cluster(case_id_new)
estat firststage, all
eststo sk_iv_approval_2: ivregress 2sls  sen_approval_binary /// 
	`controls' (sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement), 	cluster(case_id_new)
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, soto_kagan_approval_iv_with_controls) replace
estat firststage, all
*vote choice (kagan only)
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo k_iv_vc_1: ivregress 2sls  R_vote_inc  /// 
	( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement), cluster(case_id_new)
estat firststage, all
eststo k_iv_vc_2: ivregress 2sls  R_vote_inc `controls'  /// 
	( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement), cluster(case_id_new)
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, kagan_vote_choice_iv_with_controls) append
estat firststage, all

*OLS
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo sk_ols_approval_1: 	reg sen_approval_binary sen_perc_nominee_agreement sen_perc_party_agreement,  cluster(case_id_new)
eststo sk_ols_approval_2: reg  sen_approval_binary sen_perc_nominee_agreement sen_perc_party_agreement `controls',  cluster(case_id_new)
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo sk_ols_vc_1: 	reg R_vote_inc sen_perc_nominee_agreement sen_perc_party_agreement,  cluster(case_id_new)
eststo sk_ols_vc_2: 	reg  R_vote_inc sen_perc_nominee_agreement sen_perc_party_agreement `controls',  cluster(case_id_new)

esttab  sk_iv_approval_1 sk_iv_approval_2  k_iv_vc_1 k_iv_vc_2  /// 
	sk_ols_approval_1 sk_ols_approval_2  sk_ols_vc_1 sk_ols_vc_2 ///
	using  "table_06_soto_kagan.tex", /// 
	keep(sen_perc_nominee_agreement sen_perc_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Sotomayor and Kagan\label{foo})	
	
************************************
*Table A-8: Regression models evaluating whether perceptions about nominee votes affect evaluation of senators, with standard errors clustered on senators.
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*IV REGRESSIONS
eststo thomas_iv_approval_1_sc: ivregress 2sls sen_approval_binary ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement), cluster(sen_icpsr) 
estat firststage, all
eststo thomas_iv_approval_2_sc:ivregress 2sls  sen_approval_binary `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement), cluster(case_id)
estat firststage, all
*vote choice
keep if R_had_incumbent_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_iv_vc_1_sc: ivregress 2sls  R_vote_inc ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement), cluster(sen_icpsr) 
estat firststage, all
eststo thomas_iv_vc_2_sc: ivregress 2sls  R_vote_inc `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement), cluster(sen_icpsr) 
estat firststage, all
*OLS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_ols_approval_1_sc: reg sen_approval_binary sen_perceived_thomas_agreement sen_perceived_party_agreement,  cluster(sen_icpsr) 
eststo thomas_ols_approval_2_sc: reg sen_approval_binary sen_perceived_thomas_agreement sen_perceived_party_agreement `controls',   cluster(case_id)
*vote choice
keep if R_had_incumbent_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_ols_vc_1_sc: reg  R_vote_inc sen_perceived_thomas_agreement sen_perceived_party_agreement, cluster(sen_icpsr) 
eststo thomas_ols_vc_2_sc: reg  R_vote_inc sen_perceived_thomas_agreement sen_perceived_party_agreement `controls', cluster(sen_icpsr) 

esttab  thomas_iv_approval_1_sc thomas_iv_approval_2_sc  thomas_iv_vc_1_sc thomas_iv_vc_2_sc /// 
	thomas_ols_approval_1_sc thomas_ols_approval_2_sc thomas_ols_vc_1_sc thomas_ols_vc_2_sc ///
	using  "table_A8_thomas.tex", /// 
	keep(sen_perceived_thomas_agreement sen_perceived_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Clarence Thomas, with SEs clustered on senators\label{foo})	
	

*SOTOMAYOR AND KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*IV REGRESSIONS
*approval
eststo sk_iv_approval_1_sc: ivregress 2sls sen_approval_binary  (sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) , cluster(sen_icpsr) 
estat firststage, all
eststo sk_iv_approval_2_sc: ivregress 2sls  sen_approval_binary  `controls' (sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement), ///
	cluster(sen_icpsr) 
estat firststage, all
*vote choice (kagan only)
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo k_iv_vc_1_sc: ivregress 2sls  R_vote_inc ( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement), cluster(sen_icpsr) 
estat firststage, all
eststo k_iv_vc_2_sc: ivregress 2sls  R_vote_inc `controls' ( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement), cluster(sen_icpsr) 
*OLS
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo sk_ols_approval_1_sc: 	reg sen_approval_binary sen_perc_nominee_agreement sen_perc_party_agreement,  cluster(sen_icpsr) 
eststo sk_ols_approval_2_sc: reg  sen_approval_binary sen_perc_nominee_agreement sen_perc_party_agreement `controls',  cluster(sen_icpsr) 
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo sk_ols_vc_1_sc: 	reg R_vote_inc sen_perc_nominee_agreement sen_perc_party_agreement,  cluster(sen_icpsr) 
eststo sk_ols_vc_2_sc: 	reg  R_vote_inc sen_perc_nominee_agreement sen_perc_party_agreement `controls',  cluster(sen_icpsr) 

esttab  sk_iv_approval_1_sc sk_iv_approval_2_sc  k_iv_vc_1_sc k_iv_vc_2_sc  /// 
	sk_ols_approval_1_sc sk_ols_approval_2_sc  sk_ols_vc_1_sc sk_ols_vc_2_sc ///
	using  "table_A8_soto_kagan.tex", /// 
	keep(sen_perc_nominee_agreement sen_perc_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Sotomayor and Kagan, with SEs clustered on senators\label{foo})

********************************************
*tables A-15 and A-16, separate results for Democrats and Republicans (just IV models)
		
	*DEMOCRATS
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_iv_approval_1_d: ivregress 2sls sen_approval_binary ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement ///  	
	sen_actual_party_agreement) if dem_lean==1, cluster(case_id) 
estat firststage, all
eststo thomas_iv_approval_2_d:ivregress 2sls  sen_approval_binary `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement) if dem_lean==1, cluster(case_id)
estat firststage, all
*vote choice
keep if R_had_incumbent_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_iv_vc_1_d: ivregress 2sls  R_vote_inc ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement) if dem_lean==1
estat firststage, all
eststo thomas_iv_vc_2_d: ivregress 2sls  R_vote_inc `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement) if dem_lean==1
estat firststage, all
esttab  thomas_iv_approval_1_d thomas_iv_approval_2_d  thomas_iv_vc_1_d thomas_iv_vc_2_d /// 
	using  "table_A15_thomas.tex", keep(sen_perceived_thomas_agreement sen_perceived_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Clarence Thomas, Democrats only\label{foo})	


*SOTOMAYOR AND KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*approval
eststo sk_iv_approval_1_d: ivregress 2sls sen_approval_binary  /// 
		(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) if dem_lean==1 , cluster(case_id_new)
estat firststage, all
eststo sk_iv_approval_2_d: ivregress 2sls  sen_approval_binary /// 
	`controls' (sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement)  if dem_lean==1, 	cluster(case_id_new)
estat firststage, all
*vote choice (kagan only)
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
keep if nominee=="kagan"
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo k_iv_vc_1_d: ivregress 2sls  R_vote_inc  /// 
	( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement)  if dem_lean==1, cluster(case_id_new)
estat firststage, all
eststo k_iv_vc_2_d: ivregress 2sls  R_vote_inc `controls'   /// 
	( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) if dem_lean==1, cluster(case_id_new)
estat firststage, all

esttab  sk_iv_approval_1_d sk_iv_approval_2_d k_iv_vc_1_d k_iv_vc_2_d /// 
	using  "table_A15_soto_kagan.tex", keep(sen_perc_nominee_agreement sen_perc_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Sotomayor and Kagan, Democrats only\label{foo})
	
	*Republicans
use "thomas_long_data.dta", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
eststo thomas_iv_approval_1_g: ivregress 2sls sen_approval_binary ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement ///  	
	sen_actual_party_agreement) if gop_lean==1, cluster(case_id) 
estat firststage, all
eststo thomas_iv_approval_2_g:ivregress 2sls  sen_approval_binary `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement) if gop_lean==1, cluster(case_id)
estat firststage, all
*vote choice
keep if R_had_incumbent_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_name, "DIXON, Alan John" ,"CRANSTON, Alan" ,"WIRTH, Timothy E." ,"RUDMAN, Warren Bruce" ,"GARN, Edwin Jacob (Jake)" ,"ADAMS, Brockman (Brock)")
eststo thomas_iv_vc_1_g: ivregress 2sls  R_vote_inc ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement) if gop_lean==1
estat firststage, all
eststo thomas_iv_vc_2_g: ivregress 2sls  R_vote_inc `controls' ( sen_perceived_thomas_agreement sen_perceived_party_agreement = sen_actual_thomas_agreement sen_actual_party_agreement) if gop_lean==1
estat firststage, all
esttab  thomas_iv_approval_1_g thomas_iv_approval_2_g  thomas_iv_vc_1_g thomas_iv_vc_2_g /// 
	using  "table_A16_thomas.tex", keep(sen_perceived_thomas_agreement sen_perceived_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Clarence Thomas, Republicans only\label{foo})	

*SOTOMAYOR AND KAGAN
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*approval
eststo sk_iv_approval_1_g: ivregress 2sls sen_approval_binary  /// 
		(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) if gop_lean==1 , cluster(case_id_new)
estat firststage, all
eststo sk_iv_approval_2_g: ivregress 2sls  sen_approval_binary /// 
	`controls' (sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement)  if gop_lean==1, 	cluster(case_id_new)
estat firststage, all
*vote choice (kagan only)
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
keep if nominee=="kagan"
keep if R_had_incumbent10_elec==1
*need to drop incumbents who didn't run or lost in primary
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")
eststo k_iv_vc_1_g: ivregress 2sls  R_vote_inc  /// 
	( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement)  if gop_lean==1, cluster(case_id_new)
estat firststage, all
eststo k_iv_vc_2_g: ivregress 2sls  R_vote_inc `controls'   /// 
	( sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) if gop_lean==1, cluster(case_id_new)
estat firststage, all

esttab  sk_iv_approval_1_g sk_iv_approval_2_g k_iv_vc_1_g k_iv_vc_2_g /// 
	using  "table_A16_soto_kagan.tex", keep(sen_perc_nominee_agreement sen_perc_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Regressions of voters' assessment of Sotomayor and Kagan, Republicans only\label{foo})	
	

*table A-21, Separate results for Sotomayor and Kagan, just IV models for approval (recall vote choice is just based on Kagan)
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 
*sotomayor
eststo s_iv_approval_1: ivregress 2sls sen_approval_binary  ///
	(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) ///
	if nominee=="sotomayor", cluster(case_id_new) 
estat firststage, all
eststo s_iv_approval_2: ivregress 2sls  sen_approval_binary   `controls' /// 
	(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) ///
	if nominee=="sotomayor", cluster(case_id_new) 
estat firststage, all
*kagan
eststo k_iv_approval_1: ivregress 2sls sen_approval_binary  ///
	(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) ///
	if nominee=="kagan", cluster(case_id_new) 
estat firststage, all
eststo k_iv_approval_2: ivregress 2sls  sen_approval_binary   `controls' /// 
	(sen_perc_nominee_agreement sen_perc_party_agreement = sen_actual_nominee_agreement sen_actual_party_agreement) ///
	if nominee=="kagan", cluster(case_id_new) 
estat firststage, all

esttab  s_iv_approval_1 s_iv_approval_2  k_iv_approval_1 k_iv_approval_2  /// 
	using  "table_A21.tex", /// 
	keep(sen_perc_nominee_agreement sen_perc_party_agreement) nomtitles  ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Separate IV approval results for Sotomayor and Kagan \label{foo})

	
***IV Regressions to create Figure 7

// •	2009-Sotomayor:
// o	R_rollcall_ledbetter
// o	R_rollcall_recoveryreinvest
// o	R_rollcall_childrenshealth
// •	2010-Kagan:
// o	R_rollcall_recoveryreinvest
// o	R_rollcall_healthreform
// o	R_rollcall_financialreform
// o	R_rollcall_enddontask
**************************************************
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement 

*USING APPROVAL
*LILLY LEDBETTER
use "CCES_soto_kagan_long", clear
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
 eststo ledbetter_sen_approval_4:ivregress 2sls  sen_approval_binary  `controls'	///
	( sen_perc_ledbetter_agreement sen_perc_party_agreement = sen_actual_ledbetter_agreement sen_actual_party_agreement), cluster(case_id_new)
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, ledbetter_approval_iv_with_controls) append			
	
*CHIP
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo CHIP_sen_approval_4: ivregress 2sls  sen_approval_binary  `controls' /// 
	( sen_perc_CHIP_agreement sen_perc_party_agreement = sen_actual_CHIP_agreement sen_actual_party_agreement), cluster(case_id_new)
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, CHIP_approval_iv_with_controls) append	

*ACA
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo aca_sen_approval_4: ivregress 2sls  sen_approval_binary  /// 
	`controls' ( sen_perc_aca_agreement sen_perc_party_agreement = sen_actual_aca_agreement sen_actual_party_agreement), cluster(case_id_new)	
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, aca_approval_iv_with_controls) append	

*DODD-FRANK
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo doddfrank_sen_approval_4:ivregress 2sls  sen_approval_binary  /// 
	`controls'	( sen_perc_doddfrank_agreement sen_perc_party_agreement = sen_actual_doddfrank_agreement sen_actual_party_agreement), cluster(case_id_new)	
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, doddfrank_approval_iv_with_controls) append	

*DON'T ASK, DON'T TELL
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo enddontask_sen_approval_4:ivregress 2sls  sen_approval_binary ///   
	`controls' ( sen_perc_enddontask_agreement sen_perc_party_agreement = sen_actual_enddontask_agreement sen_actual_party_agreement), cluster(case_id_new)	
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, dadt_approval_iv_with_controls) append	

*STIMULUS [pools both 2009 and 2010]
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo stimulus_sen_approval_4:ivregress 2sls  sen_approval_binary  `controls' /// 
	(sen_perc_stimulus_agreement sen_perc_party_agreement = 		sen_actual_stimulus_agreement sen_actual_party_agreement), cluster(case_id_new)
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, stimulus_approval_iv_with_controls) append

********************************************************
*USING VOTE CHOICE
*******************************************************
*need to drop incumbents who didn't run or lost in primary
use "CCES_soto_kagan_long", clear
keep if nominee=="kagan"
*keep only respondents with senate incumbents
keep if R_had_incumbent10_elec==1
drop if inlist(sen_cces_name, "Christopher Dodd", "George LeMieux" , "Roland Burris" , "Evan Bayh", "Samuel Brownback")
drop if inlist(sen_cces_name,  "Jim Bunning" , "Christopher 'Kit' Bond" , "Judd Gregg" , "Byron Dorgan" , "George Voinovich"  , "Arlen Specter" , "Robert Bennett")

*ACA
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo aca_sen_vote_4: ivregress 2sls  R_vote_inc  `controls'  /// 
	( sen_perc_aca_agreement sen_perc_party_agreement = sen_actual_aca_agreement sen_actual_party_agreement), cluster(case_id_new)	
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, aca_vote_choice_iv_with_controls) append	

*DODD-FRANK
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
	eststo doddfrank_sen_vote_4: ivregress 2sls  R_vote_inc /// 
	`controls' ( sen_perc_doddfrank_agreement sen_perc_party_agreement = sen_actual_doddfrank_agreement sen_actual_party_agreement), cluster(case_id_new)	
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, doddfrank_vote_choice_iv_with_controls) append	

*DON’T ASK, DON’T TELL
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo enddontask_sen_vote_4: ivregress 2sls  R_vote_inc  `controls' /// 
	( sen_perc_enddontask_agreement sen_perc_party_agreement = sen_actual_enddontask_agreement sen_actual_party_agreement), cluster(case_id_new)	
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, dadt_vote_choice_iv_with_controls) append	
 
 *STIMULUS [pools both 2009 and 2010]
local controls i.educ  female  i.race_wbh  i.age_cat  dem_lean gop_lean engage_factor sen_actual_ideo_agreement
eststo stimulus_sen_vote_4: ivregress 2sls  R_vote_inc /// 
	`controls' ( sen_perc_stimulus_agreement sen_perc_party_agreement = sen_actual_stimulus_agreement sen_actual_party_agreement), cluster(case_id_new)
regsave using "saved_regression_results_for_figure7.dta", tstat pval ci autoid addlabel(label, stimulus_vote_choice_iv_with_controls) append

*****OUTPUT FOR TABLE A-4	
*Approval	
esttab aca_sen_approval_4 CHIP_sen_approval_4 doddfrank_sen_approval_4 enddontask_sen_approval_4 ledbetter_sen_approval_4 stimulus_sen_approval_4 /// 
	using "table_A4_approval.tex", /// 
	keep(*agreement*) ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Approval - Other Roll Calls\label{foo})	
*Vote choice
esttab aca_sen_vote_4 doddfrank_sen_vote_4 enddontask_sen_vote_4 stimulus_sen_vote_4 using "table_A4_vote_choice.tex", /// 
	keep(*agreement*) ///
 	replace cells("b(star fmt(2))" "se(par)") stats(N r2)  style(tex)   ///
	title(Vote choice - Other Roll Calls\label{foo})	

**********************************
*Table A-2 Full regression results for Thomas
esttab thomas_ols_approval_2 thomas_iv_approval_2 thomas_rf_approval_2 thomas_ols_vc_2 thomas_iv_vc_2 thomas_rf_vc_2   /// 
	using "table_A2.tex",  	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Full regression results for Thomas.\label{foo})	
**********************************
*Table A-3 Full regression results for Sotomayor and Kagan
esttab sk_ols_approval_2 sk_iv_approval_2 sk_rf_approval_2 sk_ols_vc_2 k_iv_vc_2 sk_rf_vc_2   /// 
	using "table_A3.tex",  	replace cells("b(star fmt(3))" "se(par)") stats(N r2)  style(tex)   ///
	title(Full regression results for Sotomayor and Kagan\label{foo})	


	


 
